<?php
namespace app;

use think\facade\Request;

class AppAuthController extends BaseController
{
    /**
     * @var array|int
     */

    /**
     * AppAuthController constructor.
     */
    public function __construct()
    {
        if(!$this->token()){ exit(json_encode(['code' => 301, 'msg' => 'token无效或过期'])); }
    }

    public function token()
    {
        $token = Request::header('Authorization');
        if($token){
            $user = check_login($token);
            if($user){
                $this->user = $user;
                return true;
            }
        }
        return false;
    }


}
